import log from '@dfeidao/atom-nodejs/logger/log';
import operate from '@dfeidao/atom-nodejs/db/operate';
import { systemid } from '../../atom/config';

interface Message {
	filter: {
		_id: string;
		contact: string;
		contact_number: string;
		wechat_no: string;
		mail_box: string;
		qq: string;
	};
}


export default async function atom(msg: Message, action_id: string, session_id: string) {
	log('Service begin');
	// todo
	const { update, exec } = operate(action_id, session_id, systemid);
	update('contact', { "_id": msg.filter._id }, { "contact": msg.filter.contact, "contact_number": msg.filter.contact_number, "wechat_no": msg.filter.wechat_no, "mail_box": msg.filter.mail_box, "qq": msg.filter.qq });
	const res = await exec();
	log('Service end');
	return res;
}
